﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;

namespace GosWeb.Models.Db
{
    /// <summary>
    /// 健康记录
    /// </summary>
    public class MedicalRecord
    {
        //[ForeignKey("BiontID")]
        [Key]
        public Int64 MrID { get; set; }

        [Display(Name = "耳号")]
        public string AnID { get; set; }

        [Display(Name = "疾病代号")]
        [Required(ErrorMessage = "必填", AllowEmptyStrings = false)]
        public string IllCode { get; set; }

        [Display(Name = "日期")]
        [Required(ErrorMessage = "必填", AllowEmptyStrings = false)]
        [DisplayFormat(DataFormatString = "{0:d}", ApplyFormatInEditMode = true)]
        [DataType(DataType.Date)]
        public DateTime MedicalDate { get; set; }
       
        [Display(Name = "备注/症状/用药")]
        [Required(ErrorMessage = "必填", AllowEmptyStrings = false)]
        [DataType(DataType.MultilineText )]
        public string Description { get; set; }

        [NotMapped]
        [Display(Name = "疾病名")]
        public string IllName
        {
            get
            {
              Illness g = GosDBContext.GetInstance().Illnesses.Find(IllCode);
              if (g == null)
              {
                  return string.Empty;
              }
              else
              {
                  return g.Name;
              }
            }
        }


        public virtual Biont Biont { get; set; }

    }
}